/**
 * Created by lizhe on 2018/4/16.
 */
//var urladdr = "/smart-campus";
//var imgUrl = "http://192.168.201.100:8082";
$(document).ready(function(){
    $("#modal_confirm").click(function(){
        modalclose('#infomodal');
    });
});

function showmodal(name){
    $(name).modal({backdrop: "static", keyboard: false});
    centerModals(name);
}

function modalclose(name){
    $(name).modal('hide');
}
function centerModals(name) {
    var $clone = $(name).clone().css('display', 'block').appendTo('body'); var top = Math.round(($clone.height() - $clone.find('.modal-content').height()) / 2);
    top = top > 0 ? top : 0;
    $clone.remove();
    $(name).find('.modal-content').css("margin-top", top);
}

function modalinfo(info){
    $("#infomodal").modal("show");
    centerModals("#infomodal");
    document.getElementById("info").innerHTML = info;
}

//时间戳改时间
function getdate(time) {
    var now = new Date(time),
        y = now.getFullYear(),
        m = now.getMonth() + 1,
        d = now.getDate();
    return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d) + " " + now.toTimeString().substr(0, 8);
}

function getDay(time){
    var now = new Date(time),
        y = now.getFullYear(),
        m = now.getMonth() + 1,
        d = now.getDate();
    return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d);
}

//单击表单
function clicktable(table){
    var trs = document.getElementById(table).getElementsByTagName('tr');
    var t = document.getElementById(table);
    for( var i=0; i<trs.length; i++ ){
        trs[i].onmousedown = function(){
            tronmousedown(this,table);
        }
    }
}

function tronmousedown(obj,table){
    var trs = document.getElementById(table).getElementsByTagName('tr');
    for( var o=0; o<trs.length; o++ ) {
        if (trs[o] == obj) {
            trs[o].style.background = '#dff0d8';
            trs[o].style.color = '#000000';
        }
        else {
            trs[o].style.backgroundColor = '';
            trs[o].style.color = '#000000';
        }
    }
}
